<?php
include_once("init.php");
$cursor = (int)$_GET['cursor'] ? (int)$_GET['cursor'] : 0;
$count = (int)$_GET['count'] ? (int)$_GET['count'] : 30;
if($_GET["friendships"] == "friends"){
	if($_GET["name"]){
		$friends = $c->friends_by_name($_GET["name"], $cursor, $count);
		if(!$friends){
			$friends = $c->friends_by_id($_GET["name"], $cursor, $count);
		}
	}
	else{
		$friends = $c->friends_by_id($uid, $cursor, $count);
	}
}
else if($_GET["friendships"] == "followers"){
	if($_GET["name"]){
		$friends = $c->followers_by_name($_GET["name"], $cursor, $count);
		if(!$friends){
			$friends = $c->followers_by_id($_GET["name"], $cursor, $count);
		}
	}
	else{
		$friends = $c->followers_by_id($uid, $cursor, $count);
	}
}
$users = $friends["users"];
$total = $friends["total_number"];
$next_cursor = $friends["next_cursor"]?$friends["next_cursor"]:$cursor+30;
if($friends["next_cursor"]){
?>
<div name="cursor" style="display: none;"><?php echo $friends["next_cursor"]; ?></div>
<?php
}
for($i=0; $i<count($users); $i++){
	$thisUser=$users[$i];
	$thisUserName = $thisUser["screen_name"];
	$thisUserId = $thisUser["id"];
	$thisUserName = $thisUserName?$thisUserName:$thisUserId;
?>
<div class="friendsListUser<?php if(isGhost($thisUser)){echo " ghostFriend";} ?>" id="user-<?php echo $thisUser["id"]; ?>"<?php if(!$_GET["name"]){ ?> onmouseover="document.getElementById('friendsAction-<?php echo $thisUser["id"]; ?>').style.display='block';" onmouseout="document.getElementById('friendsAction-<?php echo $thisUser["id"]; ?>').style.display='none';"<?php } ?>>
<?php
if($thisUser["following"] && $thisUser["follow_me"]){
?>
<div style="margin-left:153px; margin-top:-5px; width:50px; height:50px; position:absolute; z-index:10; background: url(/images/friendsmark.png)" title="相互关注" alt="相互关注"></div>
<?php
}
?>
<div class="friendsListUserHead"><img class="friendsListUserHeadUrl" src="<?php echo $_SERVER['HTTPS']?"/qsimg/".base64_encode($thisUser["profile_image_url"]):$thisUser["profile_image_url"]; ?>"></div>
<div class="friendsListUserInfo">
<div class="friendsListUserName"><a href="/user/<?php echo $thisUserName; ?>"><?php echo $thisUserName; ?></a></div>
<div class="friendsListUserLocation"><?php echo $thisUser["location"]; ?></div>
<div class="friendsListUserActions"></div>
</div>
<div class="floatClear"></div>
<?php if(!$_GET["name"] && $_GET["friendships"] == "friends"){ ?>
<div class="friendsAction" id="friendsAction-<?php echo $thisUser["id"]; ?>"><a href="##" onclick="removeFriend('<?php echo $thisUser["id"]; ?>');return false;">取消关注</a></div>
<?php }
else if(!$_GET["name"] && $_GET["friendships"] == "followers"){ ?>
<div class="friendsAction" id="friendsAction-<?php echo $thisUser["id"]; ?>"><a href="##" onclick="removeFollower('<?php echo $thisUser["id"]; ?>');return false;">移除粉丝</a></div>
<?php } ?>
</div>
<?php
}
?>